package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface CheckGroupMapper {

    /**
     * 添加检查组
     * @param checkGroup
     */
    void insert(CheckGroup checkGroup);

    /**
     * 删除检查组
     * @param id
     */
    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteById(Integer id);

    /**
     * 分页查询
     * @param queryString
     * @return
     */
    Page<CheckGroup> pageQuery(String queryString);

    /**
     * 编辑检查组
     * @param checkGroup
     */
    void update(CheckGroup checkGroup);

    /**
     * 查询所有检查组
     * @return
     */
    @Select("select * from t_checkgroup")
    ArrayList<CheckGroup> findAll();

    /**
     * 根据检查组id查询
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);

    /**
     * 根据套餐id查询检查组集合
     * @param setmealId
     * @return
     */
    @Select("select * from t_checkgroup where id in (select checkgroup_id from t_setmeal_checkgroup where setmeal_id =#{setmealId})")
    ArrayList<CheckGroup> findBySetmealId(Integer setmealId);
}
